package com.example.tool;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.example.view.R;

public class LanguageAdapter extends BaseAdapter {
	private BaseActivity mContext = null;
	private String[] mData;

	public LanguageAdapter(BaseActivity ctx, String[] data) {
		mContext = ctx;
		mData = data;
	}

	@Override
	public int getCount() {
		return mData.length;
	}

	public void setData(String[] data) {
		mData = data;
	}


	@Override
	public Object getItem(int position) {
		return null;
	}

	@Override
	public long getItemId(int position) {
		return position;
	}

	@Override
	public View getView(final int position, View convertView, ViewGroup parent) {
		ViewHolder holder;
		if (convertView == null) {
			convertView = LayoutInflater.from(mContext).inflate(R.layout.item_language, parent, false);
			holder = new ViewHolder();
			holder.tv = (TextView) convertView.findViewById(R.id.tv);
			convertView.setTag(holder);
		} else {
			holder = (ViewHolder) convertView.getTag();
		}
		holder.tv.setText(mData[position]);
		return convertView;
	}

	static class ViewHolder {
		TextView tv;
	}

}
